package com.bckj.fastboot.upms.biz.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bckj.fastboot.core.lang.model.PageResult;
import com.bckj.fastboot.core.page.PageSupport;
import com.bckj.fastboot.upms.api.dto.SysMenuQuery;
import com.bckj.fastboot.upms.api.dto.SysMenuRequest;
import com.bckj.fastboot.upms.api.dto.TreeSelect;
import com.bckj.fastboot.upms.api.service.SysMenuRemoteService;
import com.bckj.fastboot.upms.api.vo.SysMenuVO;
import com.bckj.fastboot.upms.biz.service.SysMenuService;
import org.springframework.web.bind.annotation.*;

import lombok.RequiredArgsConstructor;
import java.util.List;


/**
 * 菜单表(SysMenu)表控制层
 *
 * @author wfc
 * @since 2023-09-14 10:11:55
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("sysMenu")
public class SysMenuController implements SysMenuRemoteService {
    /**
     * 服务
     */
	private final SysMenuService sysMenuService;
	
    /**
	 * 列表
	 *
	 * @param query req
	 * @return list
	 */
    @Override
	@GetMapping("page")
	public PageResult<SysMenuVO> page(SysMenuQuery query) {
		IPage<SysMenuVO> page = PageSupport.page(() -> sysMenuService.list(query));
		return PageResult.of(page);
	}
	
    /**
	 * 列表
	 *
	 * @param query req
	 * @return list
	 */
    @Override
	@GetMapping("list")
	public List<SysMenuVO> list(SysMenuQuery query) {
		return sysMenuService.list(query);
	}

	/**
	 * 增加
	 *
	 * @param request req
	 * @return boolean
	 */
	@Override
	@PostMapping
	public boolean save(@RequestBody SysMenuRequest request) {
		return sysMenuService.save(request);
	}

	/**
	 * 修改
	 *
	 * @param request req
	 * @return boolean
	 */
	@Override
	@PutMapping
	public boolean update(@RequestBody SysMenuRequest request) {
		return sysMenuService.update(request);
	}

	/**
	 * 移除
	 *
	 * @param id id
	 * @return boolean
	 */
	@Override
	@DeleteMapping("{id}")
	public boolean remove(@PathVariable Long id) {
		return sysMenuService.remove(id);
	}

	/**
	 * 详情
	 *
	 * @param id id
	 * @return vo
	 */
	@Override
	@GetMapping("{id}")
	public SysMenuVO details(@PathVariable Long id) {
		return sysMenuService.details(id);
	}

	@Override
	public TreeSelect tree(SysMenuQuery query) {
		return sysMenuService.tree(query);
	}

	@Override
	public boolean initKeyIndex(SysMenuQuery query) {
		return sysMenuService.initKeyIndex(query);
	}
}

